﻿using System.Collections.Generic;
using System.Collections.ObjectModel;
using JBeamLibrary.VehicleParts.Elements;

namespace JBeamLibrary.VehicleParts.Groups
{
    public class DeformGroups : Collection<DeformGroup>
    {
        #region CTORs

        /// <summary>Creates a new deformGroups collection</summary>
        public DeformGroups() { }

        /// <summary>Creates a new deformGroups collection</summary>
        /// <param name="deformGroups"></param>
        public DeformGroups(IEnumerable<DeformGroup> deformGroups)
        {
            AddRange(deformGroups);
        }

        #endregion

        #region Methods

        public void Add(string group, string materialBase, string materialDamaged)
        {
            Add(new DeformGroup(group, materialBase, materialDamaged));
        }

        public void Add(params DeformGroup[] deformGroups)
        {
            AddRange(deformGroups);
        }

        public void AddRange(IEnumerable<DeformGroup> deformGroups)
        {
            foreach (var deformGroup in deformGroups)
                Add(deformGroup);
        }

        public void Remove(string group)
        {
            for (var i = 0; i < Count; i++)
            {
                var deformGroup = this[i];
                if (!deformGroup.Group.Equals(group))
                    continue;

                RemoveAt(i);
                i--;
            }
        }

        #endregion
    }
}
